package org.openclinic.service.impl;

import java.util.Calendar;
import java.util.Date;
import java.util.List;

import org.openclinic.domain.User;
import org.openclinic.repository.UserRepository;
import org.openclinic.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
	
	@Autowired
	private UserRepository userRepository;
	
	@Override
	public List<User> findCelebratingBirthday() {
		return findCelebratingBirthday(new Date());
	}
	
	@Override
	public List<User> findCelebratingBirthday(Date date) {
		Calendar calendar = Calendar.getInstance();
		return userRepository.findCelebratingBirthday(calendar.get(Calendar.DATE), calendar.get(Calendar.MONTH) + 1);
	}
}
